<!DOCTYPE html>
    <html>
    <head>
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	    <link rel="stylesheet" type="text/css" href="../../../css/base.css" />
	    <link id="easyuiTheme" rel="stylesheet" type="text/css" href="../../../easy-ui/themes/default/easyui.css" />
	    <link rel="stylesheet" type="text/css" href="../../../easy-ui/themes/icon.css" />
	<!--    <link rel="stylesheet" type="text/css" href="../../easy-ui/demo/demo.css" />-->
	   	<script type="text/javascript" src="../../../easy-ui/jquery.min.js"></script>
	    <script type="text/javascript" src="../../../easy-ui/jquery.easyui.min.js"></script>
	    <script type="text/javascript" src="../../../js/base.js" ></script>
    </head>
	<body class="easyui-layout" style="overflow:hidden"  fit="true"   scroll="no">
		<ul id="grid" class="easyui-grid" style="width:100%;" data-options="border:true,
														region:'center',
														fit:true,
														fitColumns:true,
														rownumbers:true,
														singleSelect:false,
														toolbar:'#tb'">
			
		</ul>
		<div id="tb" style="padding:0px;height:auto;overflow:auto;">
			<div style="height:3px;"></div>
				<form id="baseForm" name="baseForm" action="" method="post" target="hiddenFrame" style="margin:0px;"> 
					<input  name="ids"  id="ids" type="hidden" ></input>
					<span style="width:2px">&nbsp;</span>	
					<span id="sys_res_1158" >
						<a href='javascript:void(-1);' onclick="addRecord();" class="easyui-linkbutton" iconCls="icon-add" plain="true" >
							新增
						</a>
					</span>
					<span id="sys_res_1159" >
						<a href='javascript:void(-1);' onclick="updateRecord();" class="easyui-linkbutton" iconCls="icon-edit" plain="true" >
							修改
						</a>
					</span>
					<span id="sys_res_1160" >
						<a href='javascript:void(-1);' onclick="deleteRecord();" class="easyui-linkbutton" iconCls="icon-remove" plain="true"  >
							删除
						</a>
					</span>	
					<span id="search_span_id" >
						<input class="easyui-textbox" id="name" name="name" 
						data-options="buttonText:'搜索',buttonIcon:'icon-search',prompt:'请输入省份名称',onClickButton:doSearch"
						style="width:256px;"/>
					</span>
				</form> 
			<div style="height:3px;"></div>	
		</div>

		<script type="text/javascript">
			gridDataUrl='../../../zcliverole/grid.do?responseFunction=grid';
	
			var search_window;
			var add_window;
			var update_window;
			var view_window;
			var gridId="grid";
			var selections; 
			
			function showSearch(){
				search_window.openModalWindow();
			}
	
			function searchWindowCallback(json){  
				var titleStr="";
				titleStr=titleStr+wiriteSearchValueLabel("searchName","名称",json.searchName,json.searchName);
				document.getElementById('accurate_search_id').title=titleStr;
				if(titleStr!=""){
					changeSearchIcon(true);
				}else{
					changeSearchIcon(false);
				}
				
				reloadPageData();
			}
	
			function addRecord(){
				add_window.openModalWindow();
			}
	
			function updateRecord(){
			 	selections = $('#grid').datagrid('getSelections');
			 	if(!selectOnlyOne(selections)){
			 		return false;
			 	}
			 	update_window.openModalWindow();
			}
	
			function viewRecord(id){
				selections=[{"id":id}];
				view_window.openModalWindow();  
			}   
	
			function deleteRecord(){
				selections = $('#grid').datagrid('getSelections');
				if(!selectMoreOne(selections)){
			 		return false;
			 	}
			 	parent.$.messager.confirm("操作提示", "您确定要删除吗?", function(data){
		            if(data){
		            	var selections = $('#grid').datagrid('getSelections');
		
						var idParams="";
					 	for(var i=0;i<selections.length;i++){
					 		if(selections[i].id==1){
					 			parent.$.messager.alert('消息提示','删除记录中有1号ID角色,该角色是默认角色不允许删除!','info');
					 			return false;
					 		}
					 	 	idParams=idParams+""+selections[i].id+",";
						}
						parent.showProgressing(); 
						document.getElementById('ids').value=idParams.substr(0,idParams.length-1)
						gridOperate(gridId,'../../../zcliverole/deleteByIds.do?responseFunction=deleteByIds',deleteRecordCallback);
		            }else {
		               
		            }
				});
			} 
	
			function deleteRecordCallback(responseResult){
				if(responseResult.slide_msg_key==1){
					parent.showSlideMsg(responseResult.slide_msg_message_key);
				}
				reloadPageDataSimple();
			}
 	
			window.onload = function(){
				add_window
				=parent.createModalWindowWithUrl('460','550','add_window','新增现场身份','../pages/basedata/liverole/form_add.html?1=1','reloadPageData','');
				
				update_window
				=parent.createModalWindowWithUrl('460','550','update_window','修改现场身份','../pages/basedata/liverole/form_update.html?1=1','reloadPageData','');
				
				view_window
				=parent.createModalWindowWithUrl('460','550','view_window','查看现场身份','../pages/basedata/liverole/form_view.html?1=1','','');
				
				parent.showProgressing();
				sendRequestAjax(gridDataUrl,grid);
			}
	
			var columns=[[
				{"field":"id","formatter":"","width":78,"title":"","align":"center","checkbox":true,"rowStyler":""},
				{"field":"name","formatter":function(value,rowData,rowIndex){   return  rowData.name; },"width":58,"title":"名称","align":"center","checkbox":false,"rowStyler":""},
				{"field":"code","formatter":function(value,rowData,rowIndex){   return  rowData.code; },"width":58,"title":"编码","align":"center","checkbox":false,"rowStyler":""},
				{"field":"des","formatter":function(value,rowData,rowIndex){   return  rowData.des; },"width":58,"title":"描述","align":"center","checkbox":false,"rowStyler":""},
				{"field":"sort","formatter":function(value,rowData,rowIndex){   return  rowData.sort; },"width":58,"title":"排序","align":"center","checkbox":false,"rowStyler":""},
				//{"field":"mustFlag","formatter":function(value,rowData,rowIndex){   return  rowData.mustFlag=='1'?"必须的":"非必须的"; },"width":58,"title":"必须的标志","align":"center","checkbox":false,"rowStyler":""},
				]];
	
			//初始化数据
     		function grid(responseResult){  
				valiAuth(responseResult);
			    $('#grid').datagrid({
			         columns:columns, 
			         pagination:true 
			    }); 
				loadPageDataCallback(responseResult);
			}
	
			//重新载入数据
			function reloadPageData(){
				parent.showProgressing();
				gridOperate('grid',gridDataUrl,loadPageDataCallback);
			}
	
			function reloadPageDataSimple(){
				gridOperate('grid',gridDataUrl,loadPageDataCallback);
			}
	
			//初始化数据
			function loadPageDataCallback(responseResult){  
				$('#'+gridId).datagrid("loaded");//不需要显示加载状态   
				$('#'+gridId).datagrid("loadData",responseResult.data);//将数据绑定到DataGrid中
		
				setPager('grid',
					responseResult.data.pageNo,
					responseResult.data.total,
					responseResult.data.pageCount,
					responseResult.data.pageStartOffset,
					responseResult.data.pageSize,
					gridDataUrl,
					grid
				);
		       
       		   parent.closeProgressing(); 
     		}
	
			document.onkeydown = function(evt){
				var evt = window.event?window.event:evt;
				if(evt.keyCode==13){
	    			$("#search_span_id").find(".textbox-button").focus();
	    			$("#search_span_id").find(".textbox-button").click();
	    			$("#search_span_id").find(".textbox-text").focus();
				}
			}
	
			$(window).resize(function(){
				$('#grid').datagrid('resize', {
					width:document.body.clientWidth,
					height:window.innerHeight,
				});
			}); 
		</script>
	</body>
</html>